<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>hello</title>
    <!-- 导入vue包 -->
    <script src="./lib/vue2.6.10.js"></script>
</head>
<body>
    <div id="app">

        <my-com1></my-com1>
        <my-com2></my-com2>
        <my-com3></my-com3>
        <my-com4></my-com4>
    </div>

    <hr>

    <div id="app2">
        <my-com4></my-com4>
        <only></only>
    </div>
    <template id="tmp1">
        <div>
            <h3>4.这是用template 在app外部定义的组件模板</h3>
        </div>
    </template>
    <template id="tmp2">
        <div>
            <h3>app2定义的私有组件</h3>
        </div>
    </template>
    <script>
        // 第一种方法，使用 Vue.extend定义全局组件返回模板对象，用Vue.component创建绑定标签
        var com1 = Vue.extend({
            template: "<h3>1.vue.extend定义的组件</h3>"
        });
        Vue.component('myCom1',com1);
        Vue.component('myCom2',Vue.extend({
            template: "<h3>2.vue.extend定义的组件2</h3>"
        }));
        Vue.component('myCom3',{
            template: "<h3>3.vue.component直接定义的组件</h3>"
        });
        Vue.component('myCom4',{
            template: "#tmp1"
        });

        var vm = new Vue({
            el: "#app"
        });

        var vm2 = new Vue({
            el: "#app2",
            components: {
                only: {
                    template: "#tmp2"
                }
            }
        });
    </script>
</body>
</html>